import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Main {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {

        Class clazz = Class.forName("UsersImpl");
        UsersImpl users = (UsersImpl) clazz.newInstance();
        String a =  users.users("使用反射新建实例对象",15);
        System.out.println(a);

        Method method = clazz.getDeclaredMethod("add",int.class,int.class);
        String b = (String) method.invoke(users,6,7);
        Test test = method.getAnnotation(Test.class);
        System.out.println(b);
        System.out.println("元注解value为："+test.value());
        System.out.println("元注解desc为："+test.desc());


        Constructor constructor = clazz.getConstructor(int.class,int.class);
        UsersImpl users1 = (UsersImpl) constructor.newInstance(58,60);
        System.out.println(users1);

    }
}
